package util;

import org.apache.commons.io.IOUtils;

import java.io.InputStream;

public class JarFileReader {
    public String read(String filepath) {
        String fileContent = null;
        InputStream inputStream = null;
        try{
            inputStream = this.getClass().getClassLoader().getResourceAsStream(filepath);
            if (inputStream != null) {
                fileContent = IOUtils.toString(inputStream);
                inputStream.close();
            }else{
                System.out.println(String.format("[*] No %s file was found in the jar",filepath));
                System.out.println("[*] FastjsonExploit exit!");
                System.exit(0);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return fileContent;
    }
}
